<?php include DIR_MODULES . 'menu/menu_main_pages.php'; ?>

<table cellpadding="0" cellspacing="0" width="100%" border="0">
	<tr>
	<?php 
            $cStanga = mysql_query("select * from dt_mod_visible 
                                    where z_id = '1'
                                    and visible = '1'
                                    and p_id = '".$_GET['id']."'
                                    order by `order`");

            if (mysql_num_rows($cStanga)>0){
	?>
		<td id="coloana_stanga_root_var" valign="top">
		<!-- coloana stanga /////////////////////////////////////// -->
                <!-- end meniu stanga ///////////////////////////////////// -->
                <?php include DIR_MODULES . 'coloane_module/coloana_stanga.php'; ?>
		<!-- end coloana stanga /////////////////////////////////// -->
		</td>
		<?php }?>
		<td class="coloana_separator" valign="top">&nbsp;</td>
		<?php 
                    if (strpos($_SERVER['REQUEST_URI'], "/index.html") || $_GET['pg'] == ''){
                        echo '<td  id="coloana_dreapta_root" valign="top">';
                    } else {
                        echo '<td id="coloana_dreapta_root_var" valign="top">';
                        $test = mysql_query("select * from dt_mod_visible where z_id = '2' and visible = '1' and p_id = '".$_GET['id']."' order by `order`");
                        //daca nu exista nici un rezultat atunci ascunde coloana
                        if (mysql_num_rows($test)>0){
                            echo '<table cellpadding="0" cellspacing="0" width="100%" border="0">';
                        } else {
                            echo '<table cellpadding="0" cellspacing="0" width="720px" border="0">';
                        }
                    }
                ?>
		<!-- mijloc si dreapta //////////////////////////////////// -->
			
				<tr>
					<td id="content" valign="top">
					<!-- content mijloc /////////////////////////////////////// -->
						<div class="mijloc_root_pages">
						<?php 
							$data = mysql_query("select * from dt_pages where p_id = '".$_GET['id']."'");
							while ($row = mysql_fetch_array($data)){
								echo '<div class="custom_h1">' . $row['p_title'] . ' <b>Daim Tour</b></div>';
								
							//if(strpos($row['p_content'], "<div><hr /></div>"))
								//$text = explode("<div><hr /></div>", $row['p_content']);
							//elseif (strpos($row['p_content'], "<hr />"))
								$text = explode("<hr />", $row['p_content']);
								
		                    $count = count($text);
		                    
		                    //paging
		                    $total_items = $count;
		                    $limit = 1;
		                    $page = 1;
		                    
		                    
		                    if((!$limit)  || (is_numeric($limit) == false) || ($limit < 1) || ($limit > 5)) {
		                    	$limit = 1; //default}
		                    }
		                    
		                    $total_pages = ceil($total_items / $limit);
		                    
		                    if ($total_items>0){
		                    	echo '<div id="paginationdemo" class="demo">';
		                    	for($i = 1; $i <= $total_pages; $i++){
		                    		$set_limit 	= $i * $limit - ($limit);
		                    		
		                    		$dataString = $text[$set_limit];
		                    		
		                    		if($i == 1){
		                    			echo '<div id="p'.$i.'" class="pagedemo _current">';
		                    			echo '<div class="general_text">'.$dataString.'</div>';
		                    			echo '</div>';
		                    		} else {
		                    			echo '<div id="p'.$i.'" class="pagedemo" style="display:none;">';
		                    			echo '<div class="general_text">'.$dataString.'</div>';
		                    			echo '</div>';
		                    		}
		                    	}
		                    	echo '<div id="demo5"></div>';
		                    	echo '</div>';
		                    }
								
								//echo '<div class="general_text">' . $row['p_content'] . '</div>';
								if ($_GET['id'] == '7'){
									$pdfs = mysql_query("select * from dt_pdf where pdf_visible = '1'");
									while ($pdfRow = mysql_fetch_array($pdfs)){
										echo '<div class="PDF_link"><a href="../../uploads/pdf_files/'.$pdfRow['pdf_link'].'">';
										echo '<img src="../../templates/default/images/icon-pdf.png" align="absmiddle" />&nbsp;';
										echo $pdfRow['pdf_title'];
										echo '</a></div>';
									}
									echo '<div class="acrobat_link">';
									echo '<a href="http://get.adobe.com/reader/">Nu ai Adobe Reader? Descarca aici <img src="../../templates/default/images/icon-reader-mic.png" align="absmiddle" /></a>';
									echo '</div>';
									echo '<div class="mijloc_hr">&nbsp;</div>';
								}
							}
						?>
						<?php 
							if ($_GET['id'] != '5'){
							$x=0;
								$data = mysql_query("select * from dt_offers where o_active = '1' and c_id != '3' order by `o_id` desc limit 0,3");
								while ($row = mysql_fetch_array($data)){
									$imgs = $offersClass->picViewForOffer($row['o_id']);
									$img = mysql_fetch_array($imgs);
									echo '<div class="mijloc_modul_corporate">';
									echo '<table class="mijloc_modul_corporate" cellpadding="0" cellspacing="0" border="0" width="100%">';
									echo '<tr>';
									echo '<td>';
									
									$categories = $dbClass->slc_db_where("dt_categories", "c_id", $row['c_id']);
									$ctgRow = mysql_fetch_array($categories);
									
									echo '<div class="corporate_pretitlu"><a href="../../categories/'.$ctgRow['c_id'].'/'.$ctgRow['c_title'].'.html">'.$ctgRow['c_title'].'</a></div>';
									if($x % 2)
										echo '<div class="leisure_titlu"><a style="color:#777777; font-weight:500;" class="link_vaca" href="../../offers/'.$row['c_id'].'/'.$row['o_id'].'/'.cleanitup($row['o_title']).'.html">'.$row['o_title'].'</a> <a href="../../offers/'.$row['c_id'].'/'.$row['o_id'].'/'.cleanitup($row['o_title']).'.html">'.$row['o_label'].'</a></div>';
									else
										echo '<div class="corporate_titlu"><a style="color:#777777; font-weight:500;" href="../../offers/'.$row['c_id'].'/'.$row['o_id'].'/'.cleanitup($row['o_title']).'.html">'.$row['o_title'].'</a> <a href="../../offers/'.$row['c_id'].'/'.$row['o_id'].'/'.cleanitup($row['o_title']).'.html">'.$row['o_label'].'</a></div>';
									echo '<div class="corporate_content">';
									echo '<a class="link_vaca" href="../../offers/'.$row['c_id'].'/'.$row['o_id'].'/'.cleanitup($row['o_title']).'.html">'.limitclear($row['o_small_desc'], 150).'...</a>';
									echo '</div>';
									if ($row['o_price'] != '')
										echo '<div class="corporate_postcontent">De la <b>'.$row['o_price'].'</b> '.$row['o_price_type'].'</div>';
									echo '</td>';
									
									$photos = mysql_query("select * from dt_offers_photos where o_id = '".$row['o_id']."'");
									$photoRow = mysql_fetch_array($photos);
									
									if ($photoRow['oImg_file'] != ''){
										echo '<td align="right" valign="bottom" style="padding-bottom:10px;">';
										echo '<a href="../../offers/'.$row['c_id'].'/'.$row['o_id'].'/'.cleanitup($row['o_title']).'.html">';
										echo '<img class="mijloc_pic" src="../../uploads/offers/img/'.cleanitup($row['o_title']).'/thumbs/thumb_'.$img['oImg_file'].'" width="160" height="120">';
										echo '</a>';
										echo '</td>';
									}
									echo '</tr>';
									echo '</table>';
									echo '<div class="mijloc_hr">&nbsp;</div>';
									echo '</div>';
									$x++;
								}
							}
							?>
						</div>
					<!-- end content mijloc /////////////////////////////////// -->
					</td>
					<td class="coloana_separator" valign="top">&nbsp;</td>
					<?php 
						$cDreapta = mysql_query("select * from dt_mod_visible 
								where z_id = '2'
								and visible = '1'
								and p_id = '".$_GET['id']."'
								order by `order`");
						//daca nu exista nici un rezultat atunci ascunde coloana
						if (mysql_num_rows($cDreapta)>0){
					?>
					<td id="content_dreapta" valign="top">
					<!-- content dreapta ////////////////////////////////////// -->
                                        <?php include DIR_MODULES . 'coloane_module/coloana_dreapta.php'; ?>
					<!-- end content dreapta ////////////////////////////////// -->
					</td>
					<?php }?>
				</tr>
			</table>
		<!-- end mijloc si dreapta //////////////////////////////// -->
		</td>
	</tr>
</table>

<script type="text/javascript">
$(function() {
	$("#demo5").paginate({
		count 		: <?php echo $total_pages;?>,
		start 		: 1,
		display     : 6,
		border					: false,
		border_color			: '#fff',
		text_color  			: '#00A5CF',
		background_color    	: 'white',	
		border_hover_color		: '#ccc',
		text_hover_color  		: '#006699',
		background_hover_color	: '#fff', 
		images					: false,
		mouse					: 'press',
		onChange     			: function(page){
        $('._current','#paginationdemo').removeClass('_current').hide();
        	$('#p'+page).addClass('_current').show();
        }
	});
});
</script>